﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Data.SqlClient;

namespace VerdePimienta2._0
{
    class RellenarComboEmpleados
    {
        string constring = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\VP\\des_VP.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
        //string constring = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\VP\\verdepimientadb.mdf;Integrated Security=True;User Instance=True";
        //string constring = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\Chema\\Mis documentos\\Visual Studio 2008\\Projects\\VerdePimienta2.0\\VerdePimienta2.0\\verdepimientadb.mdf;Integrated Security=True;User Instance=True";
        public void RellenarComboE(ComboBox combo)
        {
            SqlConnection c = new SqlConnection(constring);
            c.Open();
            SqlDataAdapter da = new SqlDataAdapter("Select * from Empleados where Baja = '0'", c);
            DataSet ds = new DataSet("Empleados");
            da.FillSchema(ds, SchemaType.Source, "Empleados");
            da.Fill(ds, "Empleados");
            DataTable dt = ds.Tables["Empleados"];
            combo.DataSource = ds.Tables["Empleados"].DefaultView;
            combo.DisplayMember = ds.Tables["Empleados"].Columns["NumUsuario"].ToString();
            combo.ValueMember = "NumUsuario";
            combo.SelectedIndex = -1;           
        }
        
    }
}
